# Contributor: Tom Lebreux <me@tomlebreux.com>
# Maintainer: Tom Lebreux <me@tomlebreux.com>
pkgname=openrc-exporter
pkgver=0.0.2
pkgrel=5
pkgdesc="Prometheus exporter for OpenRC"
url="https://sr.ht/~tomleb/openrc-exporter"
arch="all"
license="AGPL-3.0-only"
makedepends="go openrc-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
pkgusers="openrc-exporter"
pkggroups="openrc-exporter"
source="
	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~tomleb/openrc-exporter/archive/$pkgver.tar.gz
	openrc-exporter.initd
	openrc-exporter.confd
	"
options="!check" # No tests yet

build() {
	CGO_ENABLED=1 go build -v -ldflags "-X main.version=$pkgver" \
		-trimpath ./cmd/openrc-exporter
}

check() {
	go test ./...
}

package() {
	install -Dm755 openrc-exporter "$pkgdir"/usr/bin/openrc-exporter

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="f593bb6e9f462527cd0a527539be576cbab361911fc19c9170f3e2da64093011eefa5a28bd527e07b2fdb4b8143bbd59b2590f9be0305b7d909a9039366f6a54  openrc-exporter-0.0.2.tar.gz
674cc2095b5ff46f59240f3a7a76b5fe0f3824eccaaa952d56d41a8dbef7e022dbff77eb210615dab8914b6a458bfa2fdc9ccb41d3beeda358e259daf4665597  openrc-exporter.initd
53fe95875b1f91acb91afa6e878885c2716d5b356ba535c20fc5ad4d8bf37ff4807c14b6379e82387348dde81dc3c0c421598736b48b0d3ddf337c69de2aa0a5  openrc-exporter.confd"
